﻿/// <reference path="../_references.js" />
(function (e) {

    var buildMessage = function (type, message) {
        var div = $("<div>");
        div.addClass("alert");
        div.addClass("alert-" + type);
        div.html(message);
        var bt = $("<button>");
        bt.addClass("close");
        bt.attr("data-dismiss", "alert");
        bt.html("×");
        div.prepend(bt);
        return div;
    };
    var flushMessage = function (cont, message) {
        cont.append(message);
        message.hide();
        message.fadeIn();
        setTimeout(function () {
            message.fadeOut(function() {
                message.remove();
            });
        }, 2500);
    };
    e.flashMessages = function (container) {
        this.cont = container;
    };
    e.flashMessages.prototype = {
        success: function (message) {
            flushMessage(this.cont, buildMessage("success", message));
        },
        error: function (message) {
            flushMessage(this.cont, buildMessage("error", message));
        },
        info: function (message) {
            flushMessage(this.cont, buildMessage("info", message));
        }
    };
} (this.eg = this.eg || {}));